benchd mail: the mailroom and the wake reactor, proven on real agents - #342
Open
Wirasm wants to merge 2 commits into
Open
benchd mail: the mailroom and the wake reactor, proven on real agents#342Wirasm wants to merge 2 commits into
Wirasm wants to merge 2 commits into
Conversation
…nt proof benchd owns agent-to-agent mail. Three new verbs over the same socket and log: mail/send delivers a front-matter markdown file into mail/<handle>/inbox (files are the record; a mailbox is created on first delivery, so mail to a handle nobody hosts simply waits and the response says so honestly); mail/list is metadata only with caps reported; mail/read is body plus retirement — inbox moves to read/, nothing is ever deleted. The wake is a reactor, not a mailbox feature: mail/sent to a live session's handle queues a wake, and the reactor pastes 'You have mail from <sender>: <path>' — the retired path, never the body — into the recipient's pty once it has been idle past the gate. The loop cap is a per-recipient token bucket (burst 6, one per minute) in the courier, the only place that knows a wake happened because it caused it (helm #320); a capped wake logs wake/capped and the mail waits safely unread. Sessions claim handles at spawn (--name, default the session id): validated, unique, and 'operator' reserved — addressable by anyone, claimable by no session. The daemon declares BENCH_SESSION, BENCH_HANDLE and BENCH_DIR into every pty, so 'bench mail send' inside an agent needs no flags and lands in the right mailroom. Proven with real agents, first run green (just mail-proof): 100 seeded as mail to a claude, +1 per hop through codex and pi via the production reactor and mailroom, 103 collected back — event trail mail/sent → agent/woken ×4 → mail/read. Conformance grows to 27 tests: the wake observed end to end through the relay (path present, body absent), retirement at delivery, the cap starving wakes but never mail, and the handle reservations. Also completes #341's R3 honestly: that PR typed the daemon's payloads but the CLI half of the patch never applied — the disposition comment overclaimed. The CLI now builds every payload from bench-wire's own types. Gate green: 27 conformance + 4 mail + 6 session + 9 wire tests.
…cuted The intelligence stays with the agents: the skill states what the mailroom mechanically does — your address is BENCH_HANDLE, a wake is one line carrying a path never a body, wakes are idle-gated and capped while mail waits unread, listings are metadata, read retires, files are the record — and prescribes nothing. Etiquette and protocols get added the day a real failure earns them. Per the executed-docs rule, the snippets are not prose that can drift: a conformance test extracts every bash fence from SKILL.md and runs it in order against a real daemon, then asserts the sequence did what the skill says (the read snippet retired the sent message).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The mail milestone, reordered ahead of attention on the operator's ruling: agent-to-agent comms, simple, logged, and portable — mailbox is mailbox, and the wake is a reactor.
Three new verbs over the existing socket and log. `mail/send` writes a cat-friendly front-matter markdown file into `mail//inbox/` — a mailbox is created on first delivery, so mail to a handle nobody hosts waits, and the response says `no-live-session` honestly. `mail/list` is metadata only (sender/subject/time/read-state, bodies never) with caps reported. `mail/read` returns the body and retires the message — inbox moves to `read/`, nothing is ever deleted. Sessions claim handles at spawn (`--name`, default the session id): validated, unique, `operator` reserved as addressable-never-claimable. The daemon declares `BENCH_SESSION`/`BENCH_HANDLE`/`BENCH_DIR` into every pty, so `bench mail send` inside an agent needs no flags.
The wake is deliberately not a mailbox feature: a reactor answers `mail/sent` by pasting `You have mail from : ` — the retired path, never the body — into the recipient's pty once idle. The loop cap is a per-recipient token bucket (burst 6, refill 1/min) in the courier, the only place that can count wakes (helm #320's measurement); capped mail waits safely unread.
Proven on real agents, first run green — `just mail-proof` spawns real claude, codex and pi into daemon ptys and passes a number around the ring as mail, +1 per hop through the production mailroom and reactor: 100 seeded, 103 collected, event trail `mail/sent → agent/woken` ×4 → `mail/read`. Conformance grows to 27 tests against the real binaries: the wake observed end to end through the relay (path present, body absent), retirement at delivery, the cap starving wakes but never mail, and the handle reservations.
One correction carried in this PR: #341's R3 disposition overclaimed — the daemon's payloads were typed there but the CLI half of the patch silently failed to apply. The CLI now builds every payload from `bench-wire`'s types, completing it.
Validation: `bash daemon/test.sh` green — fmt, clippy `-D warnings`, 27 conformance + 4 mail + 6 session + 9 wire tests — plus `just mail-proof` (three real agents) and `just live-smoke`. No Swift file touched.